package Chapter2.Comparing.c9;

public class Test3 {
    public static void main(String[] args) {
        Thread th1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i=1;i<10;i++) {
                    System.out.println("aaa");
                    try{
                        Thread.sleep(10);
                    }
                    catch (InterruptedException e) {
                        e.printStackTrace();;
                    }
                }
            }
        });

        Thread th2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i=1; i<10; i++) {
                    System.out.println("ccc");
                }
                try {
                    Thread.sleep(12);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread th3 = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    System.out.println(th1.getState()+ " " +th2.getState());
                    try {
                        Thread.sleep(9);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

        th3.setDaemon(true);
        th1.start(); th2.start(); th3.start();
    }
}
